import 'package:flutter/material.dart';

class UserPage extends StatelessWidget {
  const UserPage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0.0,
        backgroundColor: Colors.white,
        actions: <Widget>[
          new IconButton(
              icon: ImageIcon(
                AssetImage('assets/icons/my_setup_icon.png'),
                color: Color(0xFF2e3033),
              ),
              onPressed: () {})
        ],
      ),
      body: Scrollbar(
        child: SingleChildScrollView(
          child: Container(
            decoration: new BoxDecoration(
              color: Colors.white,
            ),
            child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  // 用户信息
                  UserInfo(),
                  Padding(padding: EdgeInsets.only(top:15.0),),
                  _actionItem(
                      title: '我的订单',
                      image: AssetImage('assets/icons/my_order_icon.png')),
                  _actionItem(
                      title: '我的下载',
                      image: AssetImage('assets/icons/my_download_icon.png')),
                  Padding(
                    padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 25.0),
                    child: Container(width: double.infinity, height: 2.0, color: Color(0xFFEDEDED),),
                  ),
                  _actionItem(
                      title: '入学测评',
                      image: AssetImage('assets/icons/my_evaluation_icon.png')),
                  _actionItem(
                      title: '问卷调研',
                      image: AssetImage('assets/icons/my_question_icon.png')),
                  _actionItem(
                      title: '机考报考',
                      image: AssetImage('assets/icons/my_pcexam_icon.png')),
                  _actionItem(
                      title: '活动',
                      image: AssetImage('assets/icons/my_activity_icon.png')),
                  Padding(
                    padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 25.0),
                    child: Container(width: double.infinity, height: 2.0, color: Color(0xFFEDEDED),),
                  ),
                  _actionItem(
                      title: '在线客服',
                      image: AssetImage('assets/icons/my_customer_icon.png')),
                  _actionItem(
                      title: '系统反馈',
                      image: AssetImage('assets/icons/my_feedback_icon.png')),
                ]),
          ),
        ),
      ));
  }

  Padding _actionItem({String title, AssetImage image}) {
    return Padding(
        padding: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 25.0),
        child: Row(
          children: <Widget>[
            Image(
              image: image,
              width: 25.0,
            ),
            Padding(
              padding: const EdgeInsets.only(left: 18.0),
              child: Text(
                title,
                style: TextStyle(color: Color(0xFF2E3033), fontSize: 18.0),
              ),
            ),
            Flexible(fit: FlexFit.tight, child: SizedBox()),
            Image.asset('assets/icons/base_arrow_right.png', width: 10),
          ],
        ));
  }
}

class UserInfo extends StatelessWidget {
  const UserInfo({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DecoratedBox(
      decoration: BoxDecoration(boxShadow: [
        //阴影
        BoxShadow(
            color: Colors.grey[100],
            offset: Offset(0.0, 1.0), //阴影xy轴偏移量
            blurRadius: 8.0, //阴影模糊程度
            spreadRadius: 0 //阴影扩散程度
            )
      ], color: Colors.white),
      child: Padding(
        padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0),
        child: Row(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.symmetric(vertical: 6.0, horizontal: 0.0),
              child: ClipOval(
                child: Image.asset('assets/icons/student.png', width: 70),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(left: 20.0,bottom:10),
              child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Row(children: <Widget>[
                      Text('小恒学会计',
                        style: TextStyle(
                          color:Color(0xFF2E3033),
                          fontSize: 24.0,
                          fontWeight: FontWeight.w700,
                          height: 2.0),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(left:5.0,top:10.0),
                        child: Image.asset('assets/icons/my_sex_man.png', width: 14),
                      )
                    ]),
                    Text('在恒企，遇见不一样的自己',
                      style: TextStyle(
                        color:Color(0xFFA3ABB8),
                        fontSize:16.0,
                      ),
                    ),
                  ]),
            ),
            Flexible(fit: FlexFit.tight, child: SizedBox()),
            Image.asset('assets/icons/base_arrow_right.png', width: 10),
          ],
        ),
      ),
    );
  }
}
